home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_force_push.cog < prev    next >
Text File  |  1998-02-25  |  6KB  |  234 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # FORCE_PULL.COG
  4. #
  5. # FORCEPOWER Script - Force Pull
  6. #  Basic Power
  7. #  Bin 38
  8. #
  9. # [YB]
  10. #
  11. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  12.  
  13.  
  14. symbols
  15.  
  16. template    powerup                          local
  17.  
  18. int         player                           local
  19. int         victim                           local
  20. int         potential                        local
  21. int         throwThing                       local
  22.  
  23. flex        cost=20.0                        local
  24. flex        targetcost=5                     local
  25. flex        targetcount=0                    local
  26. int         rank                             local
  27. flex        mana                             local
  28. flex        dot                              local
  29. flex        maxDot                           local
  30.  
  31. int         type                             local
  32. int         retval=0                         local
  33.  
  34. sound       pullSound=ForcePull01.WAV        local
  35.  
  36. int         inbubble=0                       local
  37.  
  38. message     startup
  39. message     activated
  40. message     deactivated
  41. message     pulse
  42. message     newplayer
  43. message     killed
  44. message     deselected
  45. message     selected
  46. message     enterbubble
  47. message     exitbubble
  48.  
  49. end
  50.  
  51. # ========================================================================================
  52.  
  53. code
  54.  
  55. startup:
  56.    player = GetLocalPlayerThing();
  57.    inbubble = 0;
  58.  
  59.    Return;
  60.  
  61. # ........................................................................................
  62.  
  63. activated:
  64.    if(inbubble) Return;
  65.  
  66.    // Cannot use power if blinded
  67.    if(GetActorFlags(player) & 0x800) Return;
  68.  
  69.    if(IsInvActivated(player, 38)) Return;
  70.  
  71.    mana = GetInv(player, 14);
  72.    rank = GetInv(player, 38);
  73.  
  74.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  75.    {
  76.       victim = -1;
  77.       SetInvActivated(player, 38, 1);
  78.       SetPulse(0.33);
  79.       SetBinWait(player, 38, 1.0);
  80.    }
  81.    Return;
  82.  
  83. # ........................................................................................
  84.  
  85. pulse:
  86.    targetCount = targetCount + 1;
  87.    if(targetCount == 3)
  88.    {
  89.       if(GetInv(player, 64) != 1) ChangeInv(player, 14, -targetCost);
  90.       targetCount = 0;
  91.    }
  92.  
  93.    // Check all things for our victim.
  94.    victim = -1;
  95.    maxDot = 0;
  96.  
  97.    // Search for all players and actors.
  98.    potential = FirstThingInView(player, 20 + 15 * rank, 5.5, 0x404);
  99.    while(potential != -1)
  100.    {
  101.       if(
  102.          HasLOS(player, potential) &&
  103.          (potential != player) &&
  104.          (VectorDist(GetThingPos(player), GetThingPos(potential)) <= (0.5 + rank / 2)) &&
  105.          !(GetThingFlags(potential) & 0x200) &&
  106.          !(GetActorFlags(potential) & 0x100) &&
  107.          !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)) &&
  108.          (jkGetBubbleDistance(potential) > 1.0)
  109.         )
  110.       {
  111.          dot = ThingViewDot(player, potential);
  112.          if(dot > maxDot)
  113.          {
  114.             victim = potential;
  115.             maxDot = dot;
  116.          }
  117.       }
  118.       potential = NextThingInView();
  119.    }
  120.  
  121.    // If we have a victim...
  122.    if(victim != -1)
  123.    {
  124.       jkSetTargetColors(18, 19, 20);
  125.       jkSetTarget(victim);
  126.    }
  127.    else
  128.    {
  129.       jkEndTarget();
  130.    }
  131.  
  132.    Return;
  133.  
  134. # ........................................................................................
  135.  
  136. deactivated:
  137.  
  138.    if((victim == -1) || (GetThingHealth(player) <= 0) || inbubble)
  139.    {
  140.       call stop_power;
  141.       Return;
  142.    }
  143.  
  144.    SetPulse(0);
  145.    jkEndTarget();
  146.  
  147.    mana = GetInv(player, 14);
  148.  
  149.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  150.    {
  151.       if(HasLOS(player, victim))             // check that we still have a LOS on it...
  152.       {
  153.          PlayMode(player, 24);
  154.          PlaySoundThing(pullSound, player, 1.0, -1, -1, 0x80);
  155.          if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
  156.  
  157.          // Send a "force disturbance"...
  158.          if(!IsMulti())
  159.             SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 38, 0, 0, 0);
  160.  
  161.          SetBinWait(player, 38, 0.6);
  162.  
  163.          throwThing = -1;
  164.          type = GetThingType(victim);
  165.          if(type == 2)                       // ACTOR
  166.          {
  167.             DetachThing(victim);
  168.             ApplyForce(victim, VectorScale(VectorNorm(VectorSub(GetThingPos(victim),GetThingPos(player))), 120 * rank));
  169.             SetInvActivated(player, 38, 0);
  170.             Return;
  171.          }
  172.          else
  173.          if(type == 10)                      // OTHER PLAYER
  174.          {
  175.             if(!(GetThingFlags(victim) & 0x200))
  176.                retval = SkillTarget(victim, player, 38, rank);
  177.             SetInvActivated(player, 38, 0);
  178.             victim = -1;
  179.             Return;
  180.          }
  181.       }
  182.    }
  183.  
  184.    SetInvActivated(player, 38, 0);
  185.    Return;
  186.  
  187. # ........................................................................................
  188.  
  189. selected:
  190.    jkPrintUNIString(player, 38);
  191.    Return;
  192.  
  193. # ........................................................................................
  194.  
  195. deselected:
  196.    call stop_power;
  197.    Return;
  198.  
  199. # ........................................................................................
  200.  
  201. killed:
  202.    if(GetSenderRef() != player) Return;
  203.  
  204. newplayer:
  205.    call stop_power;
  206.    Return;
  207.  
  208. # ........................................................................................
  209.  
  210. enterbubble:
  211.    inbubble = 1;
  212.    call stop_power;
  213.    Return;
  214.  
  215. # ........................................................................................
  216.  
  217. exitbubble:
  218.    inbubble = 0;
  219.    Return;
  220.  
  221. # ........................................................................................
  222.  
  223. stop_power:
  224.    SetPulse(0);
  225.    SetInvActivated(player, 38, 0);
  226.    victim = -1;
  227.    jkEndTarget();
  228.  
  229.    Return;
  230.  
  231. end
  232.  
  233.  
  234.